<%@ page import="databeans.*"%>
<%@ page import="java.util.*" %>
<%@ page import="helper.*"%>

<jsp:include page="../common/header.jsp" />

<title>Carnegie Financial Services - View Transaction History</title>
<script type="text/javascript">
	$(document).ready(function() { 
		
		$('#trans-history').colorize({ hoverColor:'none', ignoreHeaders :true, hiliteColor :'none' });

	});
</script>
</head>

<body>
	<div id="container">
    	<div id="header">
        	<h2>Carnegie Financial Services</h2>
    		<jsp:include page="../common/top-menu.jsp" />
    		<div id="top-panel">
	            <div id="panel">
	                <ul>
	                	<li><a href="customerViewTransactionHistory.do" class="invoices current" id="">View Share Transactions</a></li>
	                    <li><a href="customerViewPaymentHistory.do" class="invoices" id="">View Check Transactions</a></li>
	                   <!-- <li><a href="#" class="useredit" id="">View Pending Transactions</a></li>  --> 
	                </ul>
	            </div>
	      	</div>
    		
      </div>
        <div id="wrapper">
            <div id="content">
           	<div id="box">
	           	<h3>Transaction History</h3>
	           	<jsp:include page="../common/messages.jsp"/>
	           	<% 
	           	ArrayList<Integer> transIDs = (ArrayList<Integer>)request.getAttribute("transIDs");
	           	ArrayList<String> transDates_execute = (ArrayList<String>)request.getAttribute("transDates_execute");
	       	  	ArrayList<String> transDates_submit = (ArrayList<String>)request.getAttribute("transDates_submit");
				ArrayList<String> transDates = (ArrayList<String>)request.getAttribute("transDates");
				ArrayList<String> transTypes = (ArrayList<String>)request.getAttribute("transTypes");
				ArrayList<String> fundNames = (ArrayList<String>)request.getAttribute("fundNames");
				ArrayList<Long> numOfShares = (ArrayList<Long>)request.getAttribute("numOfShares");
				ArrayList<Long> sharePrices = (ArrayList<Long>)request.getAttribute("sharePrices");
				ArrayList<Long> amounts = (ArrayList<Long>)request.getAttribute("amounts");
				ArrayList<String> statuses = (ArrayList<String>)request.getAttribute("statuses"); 
				  if (transTypes.size()==0){
				  %>
				  <br/>
				  <p class="pad-left-20"><b>You have no transactions so far.</b></p>
				  <br/>
				  <br/>
				  &nbsp;
				 <% 
				 }else{
				 %>
	           	<div class="trans-history">
	              		<table id="trans-history">
	              			<thead>
							<tr>
								<th>ID</th>
	                           	<th>Execute Date</th>
	                           	<th>Submit Date</th>
	                               <th>Type</th>
	                               <th>Fund</th>
	                               <th>Shares</th>
	                               <th>Share Price</th>
	                               <th>$ Amount</th>
	                               <th>Status</th>
	                           </tr>
						</thead>
						<tbody>
						<%for(int i=0; i<transTypes.size(); i++){ %>
							<tr>
								<td><%=transIDs.get(i) %></td>
								<td><%=transDates_execute.get(i).toString()%></td>
								<td><%=transDates_submit.get(i).toString()%></td>
								<td><%=transTypes.get(i) %></td>
								<td><%=fundNames.get(i) %></td>
								<td style="text-align:right;padding-right:10px;"><%if(numOfShares.get(i).doubleValue()==0.00) out.println(" - "); else out.println(helper.Formatter.prepShareToView(numOfShares.get(i))); %></td>
								<td style="text-align:right;padding-right:10px;"><% 
									if(sharePrices.get(i).doubleValue()<0)
								    	out.println("Processing"); 
								    else if(sharePrices.get(i).doubleValue()==0)
								    	out.println("No Fund History founded."); 
								    else
								    	out.println("$" + helper.Formatter.prepCashToView(sharePrices.get(i)));
								    %>
								</td>
								<td style="text-align:right;padding-right:10px;"><%if(amounts.get(i).doubleValue()== 0.00) out.println(" - "); else out.println("$" + helper.Formatter.prepCashToView(amounts.get(i))); %></td>
								<td>
									<%if(statuses.get(i).equals("Pending")) { %>
										<span class="pending pad-left-20">Pending</span>
									<%}else if(statuses.get(i).equals("Approved")){ %>
										<span class="tick pad-left-20">Approved</span>
									<%} %>
								</td>
							</tr>
						<% } %>
						</tbody>
					</table>
	              	</div>
	              	<!-- 
	              	<div class="navigation_pages">
					<a href="#">Next</a>
					<a href="#">Last</a>
				</div>
				 -->
	              	<% } %>
           </div>
            </div>
            
            <jsp:include page="../common/sidebar.jsp" />
      </div>
        <jsp:include page="../common/footer.jsp" />
</div>
</body>
</html>

